<?php
    if($_SERVER['REQUEST_METHOD']=="POST")
    {
        $title = $_POST['t_title'];
        $body = $_POST['t_body'];
        include("mysql_config.php");
        $db = new PDO("mysql:host={$dbhost};dbname={$dbname}","{$dbuid}","{$dbpwd}");
        $db->query("set names utf8;");
        $result = $db->exec("insert into _article (_title,_body)values('$title','$body')");
        if($result)
        {
            echo '成功';
        }
        else
        {
            echo '失败';
        }
    }
?>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>发文章</title>


        <script type="text/javascript" src="ueditor/editor_config.js"></script>
        <script type="text/javascript" src="ueditor/editor_all.js"></script>
        <link rel="stylesheet" href="ueditor/themes/default/ueditor.css"/>




    </head>
    <body>
        <form action="" method="post">
            <div><input type="text" name="t_title"/></div>
            <div><textarea id="myEditor" name="t_body"></textarea></div>
            <div><input type="submit" value="提交" /></div>
            <script type="text/javascript">
                var editor = new baidu.editor.ui.Editor();
                editor.render("myEditor");
            </script>
        </form>
</body>
</html>
